from gevent import monkey

monkey.patch_all()  # 打补丁
import gevent
import requests
import time

def get_page(url):
    print('get :%s' % url)
    response = requests.get(url)
    if response.status_code == 200:  # 下载成功的状态
        print('%d bytes received from:%s' % (len(response.text), url))


start = time.time()
gevent.joinall([
    gevent.spawn(get_page, 'http://www.baidu.com'),
    gevent.spawn(get_page, 'https://www.yahoo.com/'),
    gevent.spawn(get_page, 'https://github.com/'),
])
stop = time.time()
print('run time is %s' % (stop - start))
